<?php
require_once('../../config.php');
Doctrine::loadModels('../../models');

	$query = new Doctrine_Query();
    $query->from('LkGlossary l')
    			->where('l.category_id = 44 OR l.item_id = 23')
            	->orderby('l.item_value, l.item_name');
    $items = $query->execute();	
    
    file_put_contents  ( "select_all.txt", $items);

    
$dom = new DomDocument('1.0');
$dom->formatOutput = true;

$root = $dom->createElement( "results" );
$dom->appendChild( $root );

	foreach ($items as $item){
		$dn = $dom->createElement( "record" );
		$dn->setAttribute( 'data', $item['item_id'] );
		$dn->setAttribute( 'label', $item['item_name'] );
		$root->appendChild( $dn );
}		

header( "Content-type: text/xml");
echo $dom->saveXML();    
    
/*/// Return XML
$str.='<results>';
	foreach ($items as $item){
		$str.='<record>';
			$str.='<data>'.$item["item_id"].'</data>';
			$str.='<label>'.$item["item_name"].'</label>';
		$str.='</record>';
	}
$str.='</results>';
   
header ("content-type: text/xml"); 
echo $str;*/

?>